package com.fyyg.common.jdpay.config;

import com.fyyg.common.fyconst.PLATFORM;
import com.fyyg.common.util.PropertiesUtil;

import java.util.Properties;

public class JdPayConfig {
   private static Properties jdProperties;
   private static String evn;
   static {
      jdProperties = PropertiesUtil.getProperties("jd.properties");
   }
   // ####################
   
   public static String rsaPrivateKey = jdProperties.getProperty("wepay.merchant.rsaPrivateKey");
   public static String desKey = jdProperties.getProperty("wepay.merchant.desKey");
   public static String rsaPublicKey = jdProperties.getProperty("wepay.jd.rsaPublicKey");
   public static String merchant = jdProperties.getProperty("wepay.merchant.num");
   public static String callbackUrl = jdProperties.getProperty("PC_URL_RETURN");
   public static String notifyUrl = jdProperties.getProperty("PC_NOTIFY_URL");
   public static String PAY_URL = jdProperties.getProperty("PAY_URL");
   
   
   public static String callbackUrl_wap = jdProperties.getProperty("WAP_URL_RETURN");
   public static String notifyUrl_wap = jdProperties.getProperty("WAP_NOTIFY_URL");
   public static String PAY_URL_wap = jdProperties.getProperty("WAP_PAY_URL");
   // ####################
   
   public static String getNotifyUrl(PLATFORM platform){
      if(JdPayConfig.evn.equals("product")){
         if(platform == PLATFORM.WX){
            return  jdProperties.getProperty("WX_NOTIFY_URL");
         }else if(platform == PLATFORM.PC){
            return  jdProperties.getProperty("PC_NOTIFY_URL");
         }else{
            return  jdProperties.getProperty("APP_NOTIFY_URL");
         }
      }else{
         if(platform == PLATFORM.WX){
            return  jdProperties.getProperty("WX_TEST_NOTIFY_URL");
         }else if(platform == PLATFORM.PC){
            return  jdProperties.getProperty("PC_TEST_NOTIFY_URL");
         }else{
            return  jdProperties.getProperty("APP_TEST_NOTIFY_URL");
         }
      }
   }

   public static String getReturnUrl(PLATFORM platform){
      if(JdPayConfig.evn.equals("product")){
         if(platform == PLATFORM.WX){
            return  jdProperties.getProperty("WX_URL_RETURN");
         }else if(platform == PLATFORM.PC){
            return  jdProperties.getProperty("PC_URL_RETURN");
         }else{
            return  jdProperties.getProperty("APP_URL_RETURN");
         }
      }else{
         if(platform == PLATFORM.WX){
            return  jdProperties.getProperty("WX_TEST_URL_RETURN");
         }else if(platform == PLATFORM.PC){
            return  jdProperties.getProperty("PC_TEST_URL_RETURN");
         }else{
            return  jdProperties.getProperty("APP_TEST_URL_RETURN");
         }
      }
   }


   public void setEvn(String evn) {
      JdPayConfig.evn = evn;
   }
}
